package com.example.ware.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.common.utils.PageUtils;
import com.common.utils.Query;

import com.example.ware.dao.WmsWareInfoDao;
import com.example.ware.entity.WmsWareInfoEntity;
import com.example.ware.service.WmsWareInfoService;


@Service("wmsWareInfoService")
public class WmsWareInfoServiceImpl extends ServiceImpl<WmsWareInfoDao, WmsWareInfoEntity> implements WmsWareInfoService {

    @Autowired
    private WmsWareInfoDao wareInfoDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<WmsWareInfoEntity> page = this.page(
                new Query<WmsWareInfoEntity>().getPage(params),
                new QueryWrapper<WmsWareInfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPageByKey(Map<String, Object> params) {
        String key = (String) params.get("key");
        QueryWrapper<WmsWareInfoEntity> wrapper = new QueryWrapper<WmsWareInfoEntity>();
        if (key != null && key.length() > 0) {
            wrapper = wrapper.like("name", key).or().like("address", key);
        }
        IPage<WmsWareInfoEntity> page = this.page(
                new Query<WmsWareInfoEntity>().getPage(params),
                wrapper
        );
        return new PageUtils(page);
    }

}